<!-- slide start -->
<div id="slide" class="slide">
    <ul>
        <tag:houseSlide id="vo">
            <li><a href="javascript:void(0)"><img src="{$vo.img}"></a></li>
        </tag:houseSlide>
    </ul>
</div>
<script>
    GH.load("js", "js-slide", "__COMMON__/js/slide.js", function(){
        utuoSlide("slide");
    });
</script>
<!-- slide end -->
<div class="subscribe">
    <h4 class="title">预约说明</h4>
    <div class="content">
        {$houseSubscribe.description}
    </div>
</div>
<div class="subscribe">
    <h4 class="title">预约看房</h4>
    <div class="content">
        <li><span>预约电话：</span><a href="tel:{$houseSubscribe.tel}">{$houseSubscribe.tel}</a></li>
        <li><span>看房地址：</span>{$houseSubscribe.address}</li>
    </div>
</div>
<div class="subscribe">
    <h4 class="title">填写下面表单进行预约</h4>
    <div class="content">
        <form method="post" aciton="__CONTROLLER__/result" id="form">
            <div class="form-item clearfix">
                <label>联系人</label>
                <div>
                    <input type="text" name="name" placeholder="请输入预约联系人名字"/>
                </div>
            </div>
            <div class="form-item clearfix">
                <label>联系人电话</label>
                <div>
                    <input type="tel" name="tel" placeholder="请输入预约联系人电话"/>
                </div>
            </div>
            <div class="form-item clearfix">
                <label>预约日期</label>
                <div>
                    <input type="date" name="date" placeholder="日期格式2014-05-01"/>
                </div>
            </div>
            <div class="form-item clearfix">
                <label>预约人数</label>
                <div>
                    <input type="number" name="count" min="0" placeholder="请输入预约人数"/>
                </div>
            </div>
            <div class="form-item clearfix">
                <label>关注户型</label>
                <div>
                    <select name="house_type">
                        {$houseSubscribe.houseType}
                    </select>
                </div>
            </div>
            <div class="form-item clearfix">
                <label>备注</label>
                <div>
                    <input type="text" name="memo" placeholder="还有什么其他需要……"/>
                </div>
            </div>
            <div class="form-item clearfix">
                <div class="submit">
                    <input type="hidden" name="sid" value="{$_GET['sid']}"/><input type="submit" class="btn btn-blue" value="提交预约"/>
                </div>
            </div>
        </form>
    </div>
</div>
<script type="text/javascript">
    (function(){
    
        var form = document.getElementById("form"), formInput = form.getElementsByTagName("input"), formSelect = form.getElementsByTagName("select");
        
        form.onsubmit = function(){
            //var res = check();
            var res = true;
            if (trim(formInput[0].value) == "" || trim(formInput[1].value) == "") {
                GH.showMessage("请填写信息");
                res = false;
            }
            if (res) {
                var data = GH.serialize(form);
                GH.ajax("__CONTROLLER__/result", data, function(data){
                    GH.showMessage(data.msg);
                }, "post");
            }
            return false;
        }
        
        //检查表单
        function check(){
            var res = false;
            //遍历验证input元素
            for (var i = 0, inputSelf; inputSelf = formInput[i]; i++) {
                if (trim(inputSelf.value) == "") {
                    GH.showMessage("请填写信息");
                    inputSelf.value = "";
                    res = false;
                    return false;
                }
                else {
                    res = true;
                }
            }
            //遍历验证select元素
            for (var i = 0, selectSelf; selectSelf = formSelect[i]; i++) {
                if (trim(selectSelf.value) == "") {
                    GH.showMessage("请填写信息");
                    selectSelf.value = "";
                    res = false;
                    return false;
                }
                else {
                    res = true;
                }
            }
            return res;
        }
        
        //去除首尾空格
        function trim(str){
            return str.replace(/(^\s*)|(\s*$)/g, "");
        }
        
    })()
</script>
